Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
electron-protocols
Advanced tools
Manage file protocols in Electron
npm install --save electron-protocols
Run the example:
npm start example
First register your protocol in main process before app.on('ready')
:
main process
const protocols = require('electron-protocols');
protocols.register('app', protocols.basepath(app.getAppPath()));
Then you can use protocols.path
to map your protocol to a file path:
renderer/main process
const protocols = require('electron-protocols');
// return the module in ${app.getAppPath()}/my/module.js
const myModule = require(protocols.path('app://my/module.js'));
Also, you are free to use protocol in html in renderer process:
<img src="app://my/image.png" />
<script src="app://my/script.js" />
It will speed up the search of protocols.path
by skip calling the remote (ipc-sync) functions.
protocol
stringfn
functionRegister a protocol so that {@link Editor.url} can use it to convert an url to the filesystem path.
The fn
accept an url Object via url.parse
Example:
const {app} = require('electron');
const protocols = require('electron-protocols');
const path = require('path');
protocols.register('app', uri => {
let base = app.getAppPath();
if ( uri.pathname ) {
return path.join( base, uri.host, uri.pathname );
}
return path.join( base, uri.host );
});
url
stringConvert a url by its protocol to a filesystem path. This function is useful when you try to get
some internal file. You can use protocols.register
to register and map your filesystem path to url.
Example:
// it will return "{your-app-path}/foobar/foobar.js"
protocols.path('app://foobar/foobar.js');
base
stringA function help you register protocol by base
path you provide.
Example:
protocols.register('app', protocols.basepath(app.getAppPath()));
MIT © 2017 Johnny Wu
FAQs
Manage file protocols in Electron
The npm package electron-protocols receives a total of 0 weekly downloads. As such, electron-protocols popularity was classified as not popular.
We found that electron-protocols demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.